home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_002 / make2 / rules.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  63 lines

  1. #include "rules.h"
  2. extern int debug;
  3.  
  4. AddDependant( pch_name, pch_target )
  5.    char *pch_name, *pch_target;
  6. {
  7.    int pos;
  8.  
  9.    pos = _Lookup( pch_target );
  10.    if( debug )
  11.       printf("Found %s at pos %d\n", pch_target, pos );
  12.    arl_Rules[ pos ].apch_depend[ arl_Rules[ pos ].c_depend++ ] = pch_name;
  13. }
  14.  
  15. char **
  16. GetDependants( pch_target )
  17.    char *pch_target;
  18. {
  19.    int pos;
  20.  
  21.    pos = _Lookup( pch_target );
  22.    return arl_Rules[ pos ].apch_depend;
  23. }
  24.  
  25. AddAction( pch_action, pch_target )
  26.    char *pch_action, *pch_target;
  27. {
  28.    int pos;
  29.  
  30.    pos = _Lookup( pch_target );
  31.    if( debug )
  32.       printf("Found %s at pos %d\n", pch_target, pos );
  33.    arl_Rules[ pos ].apch_action[ arl_Rules[ pos ].c_action++ ] = pch_action;
  34. }
  35.  
  36. char **
  37. GetActions( pch_target )
  38.    char *pch_target;
  39. {
  40.    int pos;
  41.  
  42.    pos = _Lookup( pch_target );
  43.    return arl_Rules[ pos ].apch_action;
  44. }
  45.  
  46. int n_Rules = 0;
  47. struct rule arl_Rules[ MAXRULES ];
  48.  
  49. _Lookup( pch_target )
  50.    char *pch_target;
  51. {
  52.    int pos = 0;
  53.  
  54.    arl_Rules[ n_Rules ].pch_target = pch_target;
  55.    arl_Rules[ n_Rules ].c_action = 0;
  56.    arl_Rules[ n_Rules ].c_depend = 0;
  57.    while( strcmp( arl_Rules[pos].pch_target , pch_target ) )
  58.       pos++;
  59.    if ( pos == n_Rules )
  60.       n_Rules++;
  61.    return pos;
  62. }
  63.